#include "MarsPrecompile.h"

#include "MarsGameObject.h"
#include "MarsRenderable.h"
#include "MarsMesh.h"
#include "MarsMaterial.h"
#include "MarsVertexData.h"
#include "MarsRenderer.h"
#include "MarsInputLayout.h"
#include "MarsVRamBuffer.h"
#include "MarsTexture.h"
#include "MarsSamplerState.h"
#include "MarsRenderObjectMgr.h"
#include "MarsTransformationData.h"

using namespace GObject;
using namespace Graphics;

void GameObject::AddComponent( Component* pComponent )
{
	if ( pComponent->GetType() == Component::CT_Renderable )
		m_pRenderable = static_cast< Renderable* >( pComponent );
}

GameObject::~GameObject()
{
	SAFE_DELETE( m_pRenderable );
}

void GameObject::Render( const Camera* pCamera, RenderObjectArray& arrRenderObjects )
{
	if ( m_pRenderable )
	{
		RenderObject* pRenderObject = RenderObjectMgr::Instance().GetFreeRenderObject();

		pRenderObject->SetWorldMatrix( m_pTransform->GetWorldTransformation() );
		pRenderObject->SetRenderable( m_pRenderable );
	}

}
